package StudySocket;
import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
public class Server {
    public static void main(String[] args) throws Exception {
        ServerSocket sscoket = new ServerSocket(10000);
        Socket socket = sscoket.accept();
        System.out.println("I'm Server");
        InputStream netIn = socket.getInputStream();
        OutputStream netOut = socket.getOutputStream();
        PrintWriter netOutPw = new PrintWriter(netOut);
        BufferedReader consleBr = new BufferedReader(new InputStreamReader(System.in));
        BufferedReader netInBr = new BufferedReader(new InputStreamReader(netIn));
        while (true) {
            String str = netInBr.readLine();
            System.out.println(str);
            if(str.equals("exit"))break;
            str= consleBr.readLine();
            netOutPw.println(str);
            netOutPw.flush();
            if(str.equals("exit"))break;
        }
        netOut.close();
        netIn.close();
        socket.close();
    }
}
